package com.example.park2212.merchant

import android.graphics.Color
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.MerchatBeanItem
import com.example.park2212.R
import com.example.park2212.databinding.ItemMerchantBinding

class MerchantAdapter:BaseQuickAdapter<MerchatBeanItem,BaseViewHolder>(R.layout.item_merchant) {
    lateinit var binding:ItemMerchantBinding

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemMerchantBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: MerchatBeanItem) {
        binding = DataBindingUtil.getBinding<ItemMerchantBinding>(helper.itemView)!!
        binding.bean = item

        if (item.status == "新建"){
            binding.merchantStatus.setBackgroundResource(R.drawable.shape_zhanyong)
            binding.merchantStatus.setTextColor(Color.BLUE)
        }else if (item.status == "驳回"){
            binding.merchantStatus.setBackgroundResource(R.drawable.shape_solid_orange)
            binding.merchantStatus.setTextColor(Color.RED)
        }else{
            binding.merchantStatus.setBackgroundResource(R.drawable.shape_status)
            binding.merchantStatus.setTextColor(Color.GREEN)
        }

    }
}